package com.lavida.project.system.papers.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.lavida.project.system.papers.domain.Papers;

public interface PapersMapper {
	//查询
	List<Papers> selectPapers(Papers paper);
	
	//添加
	
	void insertPapers(Papers papers);
	
	//删除数据
	void deletePapers(int id);
	
	
	Papers getPapers(int id);
	
	
	void updatePapers(Papers papers);
	
	/**
	 * 查询到期前90天的证件
	 * @return
	 */
	@Select("SELECT NAME,cerId,enddate,ABS(DATEDIFF(CURDATE(),enddate)) AS days FROM papers WHERE STATUS!='作废' AND DATEDIFF(CURDATE(),enddate)>=-89 AND DATEDIFF(CURDATE(),enddate)<1")
	List<Papers> selectExpirationPapers();
	
	/**
	 * 查询证件变更超过30天的证件
	 * @return
	 */
	@Select("SELECT a.name,a.cerId FROM papers a,subpapers b WHERE a.id = b.papers_id AND b.operate='变更中' AND DATEDIFF(CURDATE(),b.date)>30")
	List<Papers> selectChangePapers();
	
}
